package com.jnu.tijian.controller;

import com.jnu.tijian.domain.Users;
import com.jnu.tijian.dto.ResponseObject;
import com.jnu.tijian.service.UsersService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理用户模块请求的控制器
 */
@RestController // Controller + ResponseBody 返回的所有数据都是json对象
public class UserController {

    @Autowired
    UsersService usersService;  // 声明接口

    /**
     * 定义处理登录请求的方法
     */
    @RequestMapping(value = "/login", method = {RequestMethod.POST})
    public ResponseObject<Users> login(@RequestBody Users users){
        System.out.println("Users: "+ users.getUserId() + ", " + users.getPassword());

        ResponseObject<Users> responseObject = usersService.login(users);

        return responseObject;
    }

    /**
     * 定义处理注册请求的方法
     */

    @RequestMapping("/register")
    public ResponseObject register(@RequestBody Users users){
        return usersService.register(users);
    }
    

    /**
     * 定义处理修改密码请求的方法
     */

    /**
     * 定义处理快捷登录请求的方法
     */
}
